/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.cultuurschuur.entity;

import java.io.*;
import java.text.DateFormat;
import java.util.*;
import javax.persistence.*;

/**
 *
 * @author Jolien
 */
@NamedQueries({
    @NamedQuery(name = "Periode.getAll", query = "select p from Periode p"),
    @NamedQuery(name = "Periode.getById", query = "select p from Periode p where p.id = ?1")
})

@Entity
public class Periode implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Temporal (TemporalType.DATE)
    private Date vertrekdatum;
    @Temporal (TemporalType.DATE)
    private Date terugkeerdatum;

    public Date getVertrekdatum() {
        return vertrekdatum;
    }

    public void setVertrekdatum(Date vertrekdatum) {
        this.vertrekdatum = vertrekdatum;
    }

    public Date getTerugkeerdatum() {
        return terugkeerdatum;
    }

    public void setTerugkeerdatum(Date terugkeerdatum) {
        this.terugkeerdatum = terugkeerdatum;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Periode)) {
            return false;
        }
        Periode other = (Periode) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        DateFormat df = DateFormat.getDateInstance();
        
        return df.format(vertrekdatum) + " - " + df.format(terugkeerdatum);
    }
    
}
